package cn.stronglink.asset.terminal.cq.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;

import cn.stronglink.asset.terminal.cq.service.CqService;
import cn.stronglink.asset.terminal.cq.vo.InventorySheetVo;
import cn.stronglink.asset.terminal.cq.vo.UploadInventoryParam;
import cn.stronglink.suite.core.base.AbstractController;

@Controller
@RequestMapping(value = "cq")
public class CqAPIController extends AbstractController {

	@Autowired
	private CqService cqService;
	
	
	/**
	 * 手持端  查询需要验收的列表  
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "qryInventory")
	public ResponseEntity<ModelMap> qryInventory(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response) {	
		List<InventorySheetVo> data = cqService.qryInventorySheetList();
		System.out.println(JSON.toJSON(data)+"盘点单");
		return setSuccessModelMap(modelMap, data);
	}	
	
	/**
	 * 上传盘点结果接口
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param paramList
	 * @return
	 */
	@RequestMapping(value = "uploadInventory")
	public ResponseEntity<ModelMap> uploadInventory(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody List<UploadInventoryParam> paramList) {	
		if(paramList!=null&&paramList.size()>0) {
			cqService.uploadInventory(paramList);
		}
		
		return setSuccessModelMap(modelMap, null);
	}	
	
	
}
